<!--#
layout("/layouts/platform.html"){
#-->
<style>
    .left_aside {
        width: 132px;
        height: 500px;
    }

    .left_tree {
        margin-top: 10px;
        margin-left: -5px;
    }

    /*当前分类标识颜色*/
    /*.left_tree .is-current .el-tree-node__content{*/
    /*    background-color: #F5F7FA;*/
    /*}*/

    .el-tree-node {
        padding-top: 7px;
    }

    .note {
        width: 100%;
        height: 320px;
    }

    .el-upload input[type=file] {
        display: none;
    }

    .avatar-uploader .el-upload {
        border: 1px dashed #d9d9d9;
        border-radius: 6px;
        cursor: pointer;
        position: relative;
        overflow: hidden;
    }

    .avatar-uploader .el-upload:hover {
        border-color: #409EFF;
    }

    .avatar-uploader-icon {
        font-size: 28px;
        color: #8c939d;
        width: 128px;
        height: 128px;
        line-height: 128px;
        text-align: center;
    }

    .avatar {
        width: 128px;
        height: 128px;
        display: block;
    }
</style>
<div id="app" v-cloak>

    <el-row class="el-table-container">
        <el-form :model="formData" style="margin: 0 50px" label-width="250px" label-position="left">
            <el-col :span="12">
                <div class="grid-content bg-purple">
                    <el-collapse accordion>
                        <!--基础配置-->
                        <el-collapse-item title="基础配置">
                            <el-form-item prop="debug" label="Debug" title="跳过token校验">
                                <el-switch
                                        v-model="formData.debug"
                                        active-color="green"
                                        inactive-color="red">>
                                </el-switch>
                            </el-form-item>
                            <el-form-item prop="gameSwitch" label="游戏入口开关">
                                <el-switch
                                        v-model="formData.gameSwitch"
                                        active-color="green"
                                        inactive-color="red">>
                                </el-switch>
                            </el-form-item>
                            <el-form-item prop="transferSwitch" label="钻石划转开关">
                                <el-switch
                                        v-model="formData.transferSwitch"
                                        active-color="green"
                                        inactive-color="red">>
                                </el-switch>
                            </el-form-item>
                            <el-form-item prop="confirmRunningOrderSecond" label="滚球单自动确认（单位秒）">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.confirmRunningOrderSecond"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                            <el-form-item prop="loginValidTime" label="Token有效时长（分钟）">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.loginValidTime"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                            <el-form-item prop="validOdds" label="有效赔率">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.validOdds"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                            <el-form-item prop="pushVideoStreamUrl" label="直播推流地址">
                                <el-input style="width: 200px"
                                          v-model="formData.pushVideoStreamUrl"
                                          controls-position="right"
                                          :min="0"></el-input>
                            </el-form-item>
                            <el-form-item prop="pullVideoStreamUrl" label="直播播放地址">
                                <el-input style="width: 200px"
                                          v-model="formData.pullVideoStreamUrl"
                                          controls-position="right"
                                          :min="0"></el-input>
                            </el-form-item>
                            <el-form-item prop="cmsVideoPlayUrl" label="点播播放地址">
                                <el-input style="width: 200px"
                                          v-model="formData.cmsVideoPlayUrl"
                                          controls-position="right"
                                          :min="0"></el-input>
                            </el-form-item>
                            <el-form-item prop="defaultHeadPicture" label="用户默认头像">
                                <el-upload
                                        class="avatar-uploader"
                                        tabindex="5"
                                        action="${base}/open/file/upload/image2"
                                        name="Filedata"
                                        :show-file-list="false"
                                        :before-upload="beforeUpload"
                                        :on-success="function(resp,file,fileList){return handlePicSuccess(resp,file,fileList,'defaultHeadPicture')}">
                                    <img id="defaultHeadPicture" v-if="formData.defaultHeadPicture"
                                         :src="formData.defaultHeadPicture"
                                         class="avatar">
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </el-collapse-item>
                        <!--消费配置-->
                        <el-collapse-item title="消费配置">
                            <el-form-item prop="selfRateMax" label="用户消费返水阈值（万分之）">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.selfRateMax"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                            <el-form-item prop="superRateMax" label="用户消费代理返水阈值（万分之）">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.superRateMax"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                            <el-form-item prop="totalRateMax" label="总消费返水阈值（万分之）">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.totalRateMax"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                        </el-collapse-item>
                        <!--分成配置-->
                        <el-collapse-item title="分成配置">
                            <el-form-item prop="giftRate" label="礼物分成默认值（百分之）">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.giftRate"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                            <el-form-item prop="viewRate" label="观点分成默认值（百分之）">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.viewRate"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                        </el-collapse-item>
                        <!--返水配置-->
                        <el-collapse-item title="返水配置">
                            <el-form-item prop="selfRate" label="用户自身返水比默认值（万分之）">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.selfRate"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                            <el-form-item prop="superRate" label="用户所属代理返水比默认值（万分之）">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.superRate"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                        </el-collapse-item>
                        <!--限制配置-->
                        <el-collapse-item title="限制配置">
                            <el-form-item prop="timeMinRestriction" label="单次最低限制">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.timeMinRestriction"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                            <el-form-item prop="timeMaxRestriction" label="单次最高限制">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.timeMaxRestriction"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                            <el-form-item prop="dayRestriction" label="每日限制">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.dayRestriction"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                            <el-form-item prop="totalRestriction" label="总限制">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.totalRestriction"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                        </el-collapse-item>
                        <!--观点配置-->
                        <el-collapse-item title="观点配置">
                            <el-form-item prop="viewReleaseLimit" label="观点发布限制">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.viewReleaseLimit"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                            <el-form-item prop="viewTitleMinLength" label="观点标题最小长度">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.viewTitleMinLength"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                            <el-form-item prop="viewTitleMaxLength" label="观点标题最大长度">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.viewTitleMaxLength"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                            <el-form-item prop="viewContentMinLength" label="观点内容最小长度">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.viewContentMinLength"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                        </el-collapse-item>
                        <!--聊天配置-->
                        <el-collapse-item title="聊天配置">
                            <el-form-item prop="userChatMsgKeepDayNumber" label="客服聊天记录保留天数">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.userChatMsgKeepDayNumber"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                            <el-form-item prop="groupLogKeepDayNumber" label="群聊天记录保留天数">
                                <el-input-number style="width: 200px"
                                                 v-model="formData.groupLogKeepDayNumber"
                                                 controls-position="right"
                                                 :min="0"></el-input-number>
                            </el-form-item>
                        </el-collapse-item>
                        <!--极光配置-->
                        <el-collapse-item title="极光配置">
                            <el-form-item prop="jgAppKey" label="极光AppKey">
                                <el-input style="width: 200px"
                                          v-model="formData.jgAppKey"
                                          controls-position="right"
                                          :min="0"></el-input>
                            </el-form-item>
                            <el-form-item prop="jgMasterSecret" label="极光密钥">
                                <el-input style="width: 200px"
                                          v-model="formData.jgMasterSecret"
                                          controls-position="right"
                                          :min="0"></el-input>
                            </el-form-item>
                        </el-collapse-item>
                        <el-collapse-item title="赛程配置">
                            <el-form-item prop="matchKey" label="赛程数据KEY">
                                <el-input style="width: 200px"
                                          v-model="formData.matchKey"
                                          controls-position="right"
                                          :min="0"></el-input>
                            </el-form-item>
                        </el-collapse-item>
                        <!--邮箱配置-->
                        <el-collapse-item title="邮箱配置">
                            <el-form-item prop="emailHost" label="邮箱地址">
                                <el-input maxlength="32"
                                          placeholder="请输入邮箱地址"
                                          v-model="formData.emailHost"
                                          type="text">
                                </el-input>
                            </el-form-item>
                            <el-form-item prop="emailPort" label="邮箱端口">
                                <el-input maxlength="32"
                                          placeholder="请输入邮箱端口"
                                          v-model="formData.emailPort"
                                          type="number">
                                </el-input>
                            </el-form-item>
                            <el-form-item prop="emailUser" label="用户">
                                <el-input maxlength="32"
                                          placeholder="请输入用户"
                                          v-model="formData.emailUser"
                                          type="text">
                                </el-input>
                            </el-form-item>
                            <el-form-item prop="emailPassword" label="密码">
                                <el-input maxlength="32"
                                          placeholder="请输入密码"
                                          v-model="formData.emailPassword"
                                          show-password
                                          type="text">
                                </el-input>
                            </el-form-item>
                            <el-form-item prop="emailTitle" label="邮件标题">
                                <el-input maxlength="32"
                                          placeholder="请输入邮件标题"
                                          v-model="formData.emailTitle"
                                          type="text">
                                </el-input>
                            </el-form-item>
                            <el-form-item prop="emailContent" label="邮件内容">
                                <el-input maxlength="128"
                                          placeholder="邮件内容"
                                          v-model="formData.emailContent"
                                          type="textarea">
                                </el-input>
                            </el-form-item>
                            <el-form-item prop="emailReceiver" label="邮件接收人">
                                <el-input maxlength="128"
                                          placeholder="邮件接收人"
                                          v-model="formData.emailReceiver"
                                          type="textarea">
                                </el-input>
                            </el-form-item>
                        </el-collapse-item>
                    </el-collapse>
                </div>
            </el-col>
        </el-form>
    </el-row>
    <el-foot>
        <el-col :span="8">
            <div class="grid-content bg-purple">
                <span>&nbsp;</span>
            </div>
        </el-col>
        <el-col :span="8">
            <div class="grid-content bg-purple-light">
                <el-button @click="forDefault()">恢复默认</el-button>
                <el-button @click="init()">重置</el-button>
                <el-button type="primary" @click="doEdit">确 定</el-button>
            </div>
        </el-col>
        <el-col :span="8">
            <div class="grid-content bg-purple">
                <span>&nbsp;</span>
            </div>
        </el-col>
    </el-foot>
</div>
<script>
    let param = new Vue({
        el: "#app",
        data: function () {
            return {
                formData: {
                    confirmRunningOrderSecond: 30,
                    debug: false,
                    transferSwitch: true,
                    gameSwitch: true,
                    selfRateMax: 15,
                    superRateMax: 35,
                    totalRateMax: 50,
                    emailContent: "CODE:[%s]",
                    emailReceiver:"",
                    emailHost: "smtp.yishenhan.cn",
                    emailPassword: "test1234",
                    emailPort: 25,
                    emailTitle: "HELLOVIDEO",
                    emailUser: "test@yishenhan.cn",
                },
                defaultFormData: {
                    confirmRunningOrderSecond: 30,
                    debug: false,
                    transferSwitch: true,
                    gameSwitch: true,
                    selfRateMax: 15,
                    superRateMax: 35,
                    totalRateMax: 50,
                    emailContent: "CODE:[%s]",
                    emailHost: "smtp.yishenhan.cn",
                    emailPassword: "test1234",
                    emailPort: 25,
                    emailTitle: "BALL-GOLDEN",
                    emailUser: "test@yishenhan.cn",
                },
                fileType: ['jpg', 'png', 'jpeg', 'gif']
            }
        },
        methods: {
            init: function () {//加载数据
                var self = this;
                sublime.showLoadingbar();//显示loading
                $.post(base + "/platform/sys/param/data", function (data) {
                    sublime.closeLoadingbar();//关闭loading
                    if (data.code == 0) {
                        for (let dataKey in data.data) {
                            var val = data.data[dataKey];
                            if (val != null) self.formData[dataKey] = val;
                        }
                    }
                }, "json");
            },
            doEdit: function () {
                var self = this;
                $.post(base + "/platform/sys/param/editDo", self.formData, function (data) {
                    self.$message({
                        message: data.msg,
                        type: data.code == 0 ? 'success' : 'error'
                    });
                }, "json");
            },
            forDefault: function () {
                for (let dataKey in this.defaultFormData) {
                    var value = this.defaultFormData[dataKey];
                    if (value != null) this.formData[dataKey] = value;
                }
            },
            handlePicSuccess: function (response, file, fileList, attrName) {// 上传图片
                if (response.code === 0) {
                    // 对象属性直接赋值不会触发试图更新，采用 Vue.set 、this.$set或者Object.assign({}，this.obj)创建新对象
                    // 或者也可以定义一个 refresh 属性 ，当数据发生改变时，该属性同时变化，也会触发视图更新
                    // this.formData.site_logo =response.data;
                    this.$set(this.formData, attrName, response.data);
                    document.getElementById("defaultHeadPicture").src = response.data;
                } else {
                    this.$set(this.formData, attrName, "");
                }
            },
            beforeUpload: function (file) {
                let isLt120M = file.size / 1024 / 1024 < 200;
                if (this.fileType.indexOf(file.name.substring(file.name.lastIndexOf(".") + 1, file.name.length)) < 0) {
                    this.$message.error('文件格式不符，仅可以上传' + this.fileType.join(','));
                    return false;
                }
                if (!isLt120M) {
                    this.$message.error('文件大小不能超过200MB');
                    return false;
                }
                return true;
            }
        },
        created: function () {
            this.init();
        }
    });
</script>
<!--#
}
#-->